﻿@using Nop.Services.Security
@model DashboardModel
@{
    //page title
    ViewBag.Title = T("Admin.Dashboard").Text;

    var permissionService = EngineContext.Current.Resolve<IPermissionService>();
    var canManageOrders = permissionService.Authorize(StandardPermissionProvider.ManageOrders);
    var canManageCustomers = permissionService.Authorize(StandardPermissionProvider.ManageCustomers);
    var canManageProducts = permissionService.Authorize(StandardPermissionProvider.ManageProducts);
}
<div class="section-title">
    <img src="@Url.Content("~/Administration/Content/images/ico-dashboard.png")" alt="" />
    @T("Admin.Dashboard")
</div>
<table class="dashboard">
    @Html.Widget("admin_dashboard_top")
    <tr>
        <td class="maincol">
            <div class="section-header">
                <div class="title">
                    <img src="@Url.Content("~/Administration/Content/images/ico-stat1.gif")" alt="" />
                    @T("Admin.Dashboard.StoreStatistics")
                </div>
            </div>
            @if (!Model.IsLoggedInAsVendor && canManageOrders)
            {
                <table class="stats">
                    <tbody>
                        <tr>
                            <td class="orderaveragereport">
                                <div class="statisticsTitle">
                                    @T("Admin.SalesReport.Average")
                                </div>
                                @Html.Action("OrderAverageReport", "Order")
                            </td>
                        </tr>
                    </tbody>
                </table>
            }
            @if (!Model.IsLoggedInAsVendor)
            {
                if (canManageOrders || canManageCustomers || canManageProducts)
                {
                    <table class="stats">
                        <tbody>
                            <tr>
                                @if (canManageOrders)
                                {
                                    <td class="orderstatistics">
                                        <div class="statisticsTitle">
                                            @T("Admin.SalesReport.Incomplete")
                                        </div>
                                        @Html.Action("OrderIncompleteReport", "Order")
                                    </td>
                                }
                                @if (canManageCustomers)
                                {
                                    <td class="customerstatistics">
                                        <div class="statisticsTitle">
                                            @T("Admin.Customers.Reports.RegisteredCustomers")
                                        </div>
                                        @Html.Action("ReportRegisteredCustomers", "Customer")
                                    </td>
                                }
                                @if (canManageProducts)
                                {
                                    <td class="search-term-statistics">
                                        <div class="statisticsTitle">
                                            @T("Admin.SearchTermReport")
                                        </div>
                                        @Html.Action("PopularSearchTermsReport", "Common")
                                    </td>
                                }
                            </tr>
                        </tbody>
                    </table>
                }
            }
            @if (canManageOrders)
            {
                <table class="stats">
                    <tr>
                        <td class="bestsellers">
                            <div class="statisticsTitle">
                                @T("Admin.SalesReport.BestSellers.ByQuantity")
                            </div>
                            @Html.Action("BestsellersBriefReportByQuantity", "Order")
                        </td>
                        <td class="bestsellers">
                            <div class="statisticsTitle">
                                @T("Admin.SalesReport.BestSellers.ByAmount")
                            </div>
                            @Html.Action("BestsellersBriefReportByAmount", "Order")
                        </td>
                    </tr>
                </table>
            }
        </td>
        @if (!Model.IsLoggedInAsVendor)
        {
            <td class="rightcol">
                @Html.Action("NopCommerceNews", "Home")
            </td>
        }
    </tr>
    @Html.Widget("admin_dashboard_bottom")
</table>
